aggregation should sort groups by a derived metric